<?php 
//引进配置信息
include 'include/init.php';
//引入数据库配置信息
include 'include/mysql.config.php';
//引入公共函数
include 'include/common.fun.php';
//公共数据
include 'data/common_data.php';



$sql='SELECT * FROM wd_case_cat';//获取分类信息
$case_cat=$db->getAll($sql);
$current=isset($_GET['page'])?$_GET['page']:1;//传递参数的当前页，没传值就默认1的页

$limit=5;//每个页面显示数量
//显示页数
$start=($current-1)*$limit;


if(isset($_GET['cat_id'])){
	$id = $_GET['cat_id'];
	$sql = "SELECT case_img_thumb,case_id,case_name FROM wd_case WHERE case_cat_id=$id ORDER BY case_addtime DESC LIMIT $start,$limit";
	$sql_count="SELECT count(case_id) as count from wd_case where case_cat_id=$id";
}else{
	$sql = "SELECT case_img_thumb,case_id,case_name FROM wd_case  ORDER BY case_addtime DESC LIMIT $start,$limit";
	$sql_count="SELECT count(case_id) as count from wd_case";
}


$case = $db->getAll($sql);
$case_count=$db->getOne($sql_count);
$count1=$case_count['count'];
$count=ceil($count1/$limit);
$page = new Page($current,$count1,$limit,5);
$page_link = $page->first()->prev()->num()->next()->show();
//加载视图页面
include 'view/case.php';